package demo3;

/**
 * @Author: XXHH
 * @CreateTime: 2025-01-12
 */
public class Dog extends Animal{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+" 正在吃狗粮...");
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof Dog)) {
            return false;
        }
        // 出现在复制
        if (this == obj) {
            return true;
        }
        // 现在判断 年龄和姓名是否一样
        // 需要对 obj强转
        Dog tmp = (Dog) obj;
        return this.name.equals(tmp.name) && this.age == tmp.age;
    }
}
